local pnum = ...
assert(pnum)

local t = Def.ActorFrame {}

if GAMESTATE:IsPlayerEnabled(pnum) then
	--fondoh
	t[#t+1] = Def.Quad {
		InitCommand=function(self)
			(cmd(y,-130;zoomto,180,320;vertalign,top;diffuse,0,0,0,0.5))(self);
			self:horizalign(pnum == PLAYER_1 and left or right);
			self:x(pnum == PLAYER_1 and -10 or 10);
		end;
	}
	--datos del perfil
	t[#t+1] = LoadFont("ArialOutline")..{
		InitCommand=function(self)
			(cmd(shadowlength,0;vertalign,top;zoom,0.75;vertspacing,39))(self);
			self:horizalign(pnum == PLAYER_1 and left or right);
			local Profile = PROFILEMAN:GetProfile(pnum)
			local text = "No ID\n00000\n0.00\n00000"
			self:diffuse(.5,.1,.1,1);
			--para agilizar cálcuos :D
			if PROFILEMAN:IsPersistentProfile(pnum) then
				local ProfileName = Profile:GetDisplayName()
				if ProfileName == "" then
					ProfileName = "No name"
				end
				local PlayCount = Profile:GetNumTotalSongsPlayed()
				local Milleage = Profile:GetTotalTapsAndHolds()
				--límite de playcount desplegados
				if PlayCount >= 99999999 then
					PlayCount = 99999999
				end
				--límite de "millas" desplegadas
				if Milleage >= 99999999 then
					Milleage = 99999999
				end
				self:diffuse(1,1,0,1);
				text = string.format("%s\n%08i\n%.2f Cal\n%08i",string.sub(ProfileName,0,12),PlayCount,Profile:GetTotalCaloriesBurned(),Milleage)
			end
			self:settext(text);
		end;
	}
	--avatar del profile :D
	--(icon de un character)
	t[#t+1] = Def.Banner {
		InitCommand=function(self)
			local CharIcon = PROFILEMAN:GetProfile(pnum):GetCharacter():GetIconPath()
			if not CharIcon then
				CharIcon = THEME:GetPathG("Common","fallback charicon")
			end
			self:Load(CharIcon);
			self:y(-75);
			self:zoomto(92,92);
			self:horizalign(pnum == PLAYER_1 and left or right);
		end;
	}
	--[[imagen que muestra si el pefil está en una USB o escrita deltro de la máquina
	t[#t+1] = Def.Sprite {
		InitCommand=function(self)
			local ProfileType
			if PROFILEMAN:IsPersistentProfile(pnum) then
				ProfileType = "_Local"
			else
				ProfileType = "_Machine"
			end
			self:Load("Profile"..ProfileType);
		end;
	}]]
end

return t